<?php
namespace app\index\controller;
use app\index\controller\BaseController;

class TempController extends BaseController {

	public function college() {
		$expert = db('expert')->order('add_time desc')->limit(2)->select();
		$this->assign('expert', $expert);
		$list = db('vedio')->order('add_time desc')->limit('2')->select();
		$this->assign('list', $list);

		$ask = db('ask a')->field('a.*,m.nick_name,m.thumb')->join('member m', 'a.uid=m.id')->order('add_time desc')->limit(4)->select();
		$this->assign('ask', $ask);

		$newstop1 = db('news')->field('id,title')->order('add_time desc')->find();
		$this->assign('newstop1', $newstop1);
		$newstop2 = db('news')->field('id,title')->order('sort desc')->find();
		$this->assign('newstop2', $newstop2);
		$this->assign('vedionum', db('vedio')->count());
		return $this->fetch();
	}

	//电子杂志
	public function news() {
		if ($this->member['user_type'] == 1) {
			$this->error('请先到个人中心订阅情报站方再查看', url('member/dingyue'));
		}
		$catesno = db('news_cate')->where('status', 1)->where('pid', 0)->where('id', 'not in', $this->member['yuetype1'])->select();
		$this->assign('catesno', $catesno);
		$cates = db('news_cate')->where('status', 1)->where('pid', 0)->where('id', 'in', $this->member['yuetype1'])->select();
		$this->assign('cates', $cates);
		$where['cate_id1'] = $cates[0]['id'];
		$this->assign('cate_id1', $where['cate_id1']);
		$res = db('news')->field('id,add_time,cate_id1')->where($where)->group('add_time')->order('add_time desc')->page(1, 9)->select();
		$this->assign('res', $res);

		return $this->fetch();
	}

}
